package DDB.Ddc;

/** 测试类 */
public class Test {
    public static void main(String[] args) {
       /* Master master = new Master();
        Dog dog = new Dog("一",1,"黑");
        Fish fish = new Fish("二",2,"白");
        Chick chick = new Chick("三",3,"无");
        master.feed(dog);
        master.feed(fish);
        master.feed(chick);*/




     //Animal o = new Animal();
        Animal[] animals = new Animal[5];
        animals[0] = new Dog("一",1,"黑");
        animals[1] = new Dog("二狗子",2,"白");
        animals[2] = new Fish("二",1,"白");
        animals[3] = new Fish("鱼",2,"黄");
        animals[4] = new Chick("三",3,"黑");
        for(int i=0;i<animals.length;i++){
            System.out.println(animals[i].name);
            animals[i].eat();
            animals[i].drink();

            if(animals[i] instanceof Dog){
                Dog dog = (Dog)animals[i];
                dog.lookHome();
            }

            if(animals[i] instanceof Chick){
                Chick chick = (Chick)animals[i];
                chick.layEggs();
            }
            if(animals[i] instanceof Swim){
                Swim s = (Swim)animals[i];
                s.swim();
            }
        }



        /*

        Animal o = new Dog("二b",2,"黑");
        Dog d = (Dog)o;
        Swim s = (Swim)o;
        //Fish f = (Fish)o; //

        System.out.println(o instanceof Dog);  //
        System.out.println(o instanceof Swim); //
        System.out.println(o instanceof Fish); //
        */


































        /*

        Master master = new Master();
        Dog dog = new Dog("小黑",2,"黑");
        Fish fish = new Fish("小金",1,"金");
        Chick chick = new Chick("小花",3,"花");
        master.feed(dog);
        master.feed(fish);
        master.feed(chick);
        */



      /*  //Animal o = new Animal();
        Animal[] animals = new Animal[5];
        animals[0] = new Dog("小黑",2,"黑");
        animals[1] = new Dog("小白",3,"白");
        animals[2] = new Fish("小金",1,"金");
        animals[3] = new Fish("小花",2,"花");
        animals[4] = new Chick("小灰",3,"灰");
        for(int i=0;i<animals.length;i++){
            System.out.println(animals[i].name);
            animals[i].eat();
            animals[i].drink();

            if(animals[i] instanceof Dog){
                Dog dog = (Dog)animals[i];
                dog.lookHome();
            }
            if(animals[i] instanceof Chick){
                Chick chick = (Chick)animals[i];
                chick.layEggs();
            }
            if(animals[i] instanceof Swim){
                Swim s = (Swim)animals[i];
                s.swim();
            }
        }

*/

        /*

        Animal o = new Dog("小黑",2,"黑");
        Dog d = (Dog)o;
        Swim s = (Swim)o;
        //Fish f = (Fish)o; //

        System.out.println(o instanceof Dog);  //
        System.out.println(o instanceof Swim); //
        System.out.println(o instanceof Fish); //
        */





    }
}




















